package game.johan.engine;
/*
Copyright (C) 2013 Johan Ceuppens

import game.johan.engine.SurfaceFetcher.ImageR;

import java.util.LinkedList;

/*
 * This class can store surfacelist and surface objects
 * It can fetch the next surface from these inside 
 * the _buffer variable
 */

class SurfaceFetcher
{
	class ImageR {
		//FIXME image
		public ImageR(/*image*/) {
			
		}
	}
	
	private int _currentindex; 
	private LinkedList _buffer = new LinkedList();
	public SurfaceFetcher() {
		_currentindex = 0;
	}
	
	public Surface get() {
		if (_currentindex < _buffer.size()) {
			Object o = _buffer.get(_currentindex);
			if (o instanceof SurfaceList) {
				SurfaceList surflist = ((SurfaceList)o);
				Surface surf = (Surface)surflist.get();
				if (surflist.isLast()) {
					_currentindex++;
				}
				return surf;
			} else {
				_currentindex++;
				return (Surface)o;
			}

		}
		return null;
	}
	
	public void put(ImageR imgr) {
		_buffer.add(imgr);
	}
	
	public void put(SurfaceList surflist) {
		_buffer.add(surflist);
	}
}